import { _cateData, _currentCate } from "../../../service/api";

Page({
  data: {
    currentCate: {},
    navList: [],
    currentIndex: 0,
  },
  onLoad: function (options) {
    this.initData();
  },
  initData() {
    _cateData().then((res) => {
      this.setData({
        navList: res.navList,
        currentCate: res.currentCate,
      });
    });
  },
  async handleItemChange(e) {
    wx.showLoading({ title: "加载中..." });
    const { id, index } = e.currentTarget.dataset;
    const res = await _currentCate(id);
    this.setData({ currentIndex: index, currentCate: res.currentCate });
    wx.hideLoading();
  },
});
